package org.example.CLI;

import org.example.command.Command;
import org.example.command.CommandInvoker;
import org.example.exception.InvalidCommandException;
import org.example.model.HTMLDocument;

import java.util.Scanner;

public class Console {

    public static void main(String[] args) {
        HTMLDocument htmlDocument = new HTMLDocument();
        CommandInvoker commandInvoker = new CommandInvoker();
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.print("Enter command: ");
            String commandStr = scanner.nextLine();
            if (commandStr.equals("exit")) {
                break;
            }
            try {
                Command command = CommandParser.parse(htmlDocument, commandInvoker, commandStr);
                commandInvoker.storeAndExecute(command);
            } catch (InvalidCommandException e) {
                System.out.println(e.getMessage());
            }
        }

    }
}
